#ifndef _dso_const_h
#define _dso_const_h

#include <nds.h>

enum WIFI_ASSOCSTATUS 
{
	ASSOCSTATUS_DISCONNECTED, // not *trying* to connect
	ASSOCSTATUS_SEARCHING, // data given does not completely specify an AP, looking for AP that matches the data.
	ASSOCSTATUS_AUTHENTICATING, // connecting...
	ASSOCSTATUS_ASSOCIATING, // connecting...
	ASSOCSTATUS_ACQUIRINGDHCP, // connected to AP, but getting IP data from DHCP
	ASSOCSTATUS_ASSOCIATED,	// Connected! (COMPLETE if Wifi_ConnectAP was called to start)
	ASSOCSTATUS_CANNOTCONNECT, // error in connecting... (COMPLETE if Wifi_ConnectAP was called to start)
};

typedef struct WIFI_ACCESSPOINT {
	char ssid[33]; // the AP's SSID - zero terminated is not necessary.. if ssid[0] is zero, the ssid will be ignored in trying to find an AP to connect to. [REQUIRED]
	char ssid_len; // number of valid bytes in the ssid field (0-32) [REQUIRED]
	u8 bssid[6]; // BSSID is the AP's SSID - setting it to all 00's indicates this is not known and it will be ignored [REQUIRED]
	u8 macaddr[6]; // mac address of the "AP" is only necessary in ad-hoc mode. [generally not required to connect]
	u16 maxrate; // max rate is measured in steps of 1/2Mbit - 5.5Mbit will be represented as 11, or 0x0B [not required to connect]
	u32 timectr; // internal information about how recently a beacon has been received [not required to connect]
	u16 rssi; // running average of the recent RSSI values for this AP, will be set to 0 after not receiving beacons for a while. [not required to connect]
	u16 flags; // flags indicating various parameters for the AP [not required, but the WFLAG_APDATA_ADHOC flag will be used]
	u32 spinlock; // internal data word used to lock the record to guarantee data coherence [not required to connect]
	u8 channel; // valid channels are 1-13, setting the channel to 0 will indicate the system should search. [REQUIRED]
	u8 rssi_past[8]; // rssi_past indicates the RSSI values for the last 8 beacons received ([7] is the most recent) [not required to connect]
	u8 base_rates[16]; // list of the base rates "required" by the AP (same format as maxrate) - zero-terminated list [not required to connect]
} Wifi_AccessPoint;

typedef enum {
	FT_NONE, 
	FT_FILE, 
	FT_DIR
} FILE_TYPE;

struct sockaddr {
	unsigned short		sa_family;
	char				sa_data[14];
};

struct hostent {
   char * h_name;
   char ** h_aliases;
   int h_addrtype;
   int h_length;
   char ** h_addr_list;
};

struct timeval {
  long tv_sec;
  long tv_usec;
};

typedef void FAT_FILE;
typedef void (*WifiPacketHandler)(int, int);

#define BIT0 (1<<0)
#define BIT1 (1<<1)
#define BIT2 (1<<2)
#define BIT3 (1<<3)
#define BIT4 (1<<4)
#define BIT5 (1<<5)
#define BIT6 (1<<6)
#define BIT7 (1<<7)
#define BIT8 (1<<8)
#define BIT9 (1<<9)
#define BIT10 (1<<10)
#define BIT11 (1<<11)
#define BIT12 (1<<12)
#define BIT13 (1<<13)
#define BIT14 (1<<14)
#define BIT15 (1<<15)

#define SCREEN_HEIGHT 192
#define SCREEN_WIDTH  256
#define RGB15(r,g,b)  ((r)|((g)<<5)|((b)<<10))

// plugin types
#define PLUGIN_NONE 0 // just a loader and unload function, possible vblank function
#define PLUGIN_FILEFORMAT 1 // used for adding launchable fileformats
#define PLUGIN_INPUT 2 // used for adding a new input stream to sound/picture/text screens, not supported yet

// function requests, data, etc
#define REQ_TYPE 0 // requesting the plugin type, return one of the above
#define REQ_EXTLIST 1 // requesting the list of extensions this plugin handles, return comma delimited
#define REQ_EXTDESC 2 // requesting the extension description for this plugin
#define REQ_SMALLICON 3 // requesting the graphic for the small icon in the browser (10x10)
#define REQ_LONGDESC 4 // requesting the 3 line file description, return 0 for nothing
#define REQ_LARGEICON 5 // requesting the 32x32 icon, return 0 for nothing
#define REQ_LOADFILE 6 // requesting the function to call when a file is loaded
#define REQ_ALTLOADFILE 7 // requesting the function to call when a file is alt-loaded
#define REQ_LOADSTRING 8 // the text displayed when the file is hilighted
#define REQ_ALTLOADSTRING 9 // the text displayed in the alternate load section

// libfb constants
#define SCREEN1 0
#define SCREEN2 1

#define FONT_GAUTAMI_10 0
#define FONT_ARIAL_9 	1
#define FONT_ARIAL_11 	2
#define FONT_CENTURY_16 3

// control characters, use with %c
#define POS_LEFT	'\b'
#define POS_RIGHT	'\a'
#define POS_UP		'\v'
#define POS_DOWN	'\f'

// constants for button graphics, use with %c again
#define BUTTON_A 1
#define BUTTON_B 2
#define BUTTON_X 3
#define BUTTON_Y 4
#define BUTTON_LEFT 5
#define BUTTON_UP 6
#define BUTTON_DOWN 14
#define BUTTON_RIGHT 15
#define BUTTON_SELECT 16
#define BUTTON_START 17
#define BUTTON_L 18
#define BUTTON_R 19
#define SCROLL_UP 20
#define SCROLL_DOWN 21

// for files
#ifndef EOF
#define EOF -1
#define SEEK_SET	0
#define SEEK_CUR	1
#define SEEK_END	2
#endif

// File attributes
#define ATTRIB_ARCH	0x20			// Archive
#define ATTRIB_DIR	0x10			// Directory
#define ATTRIB_LFN	0x0F			// Long file name
#define ATTRIB_VOL	0x08			// Volume
#define ATTRIB_SYS	0x04			// System
#define ATTRIB_HID	0x02			// Hidden
#define ATTRIB_RO	0x01			// Read only

// Sound defines normally on arm7
#define SOUND_VOL(n)	(n)
#define SOUND_FREQ(n)	((-0x1000000 / (n)))
#define SOUND_PAN(n)	((n) << 16)
#define SOUND_FORMAT_PSG    (3<<29)
#define SCHANNEL_ENABLE BIT(31)


#endif

